home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.02 Feb 90 / FuzzyBrush source / Fuzzy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-07  |  2.8 KB  |  126 lines  |  [TEXT/KAHL]

  1.  
  2. /*
  3.  *  Fuzzy Brush
  4.  *    Linda McLennan
  5.  *  COPYRIGHT © 1989 Ventana Software
  6. */
  7.  
  8. #include    "BWit.h"
  9. #include    "Fuzzy.h"
  10.  
  11. pascal void main( selector, tDataPtr, refCon, returnCode )
  12.  
  13. short            selector;
  14. ToolDataPtr        tDataPtr;
  15. Handle            *refCon;
  16. short            *returnCode;
  17.         
  18. {
  19.     DialogPtr        dLogPtr;
  20.     short            itemHit;
  21.     MenuHandle        fuzzyMenu;
  22.     FuzzyDataPtr    fzDataPtr;
  23.     EventRecord        *eventDataPtr;
  24.     char            keyHit;
  25.     GrafPtr            drawingPort;
  26.     
  27.     *returnCode = noErr;
  28.  
  29.     switch( selector )
  30.     {
  31.         case toolAbout:        
  32.             /* show about box */
  33.             CenterWindow('DLOG', tDataPtr->toolID );
  34.             dLogPtr = GetNewDialog( tDataPtr->toolID, nil, (WindowPtr)behind );
  35.             ModalDialog( nil, &itemHit );
  36.             DisposDialog( dLogPtr );
  37.             break;
  38.  
  39.         case toolSelected:
  40.             /* tool selected from palette */
  41.             FuzzyInit( tDataPtr, refCon );
  42.             if ( *refCon == nil )
  43.                 *returnCode = memFullErr;
  44.             break;
  45.  
  46.         case toolMenuInsert:
  47.             /* put up menu */
  48.             HLock( *refCon );
  49.             fzDataPtr = (FuzzyDataPtr)**refCon;
  50.             fuzzyMenu = fzDataPtr->theMenu;
  51.             if ( fuzzyMenu != nil )
  52.             {
  53.                 InsertMenu( fuzzyMenu, 0 );
  54.                 CheckItem( fuzzyMenu, fzDataPtr->whichEffect, true );
  55.             }
  56.             HUnlock( *refCon );
  57.  
  58.             DrawMenuBar();
  59.             break;
  60.  
  61.         case toolDblClick:
  62.             /* show about box */
  63.             CenterWindow('DLOG', tDataPtr->toolID );
  64.             dLogPtr = GetNewDialog( tDataPtr->toolID, nil, (WindowPtr)behind );
  65.             ModalDialog( nil, &itemHit );
  66.             DisposDialog( dLogPtr );
  67.             break;
  68.  
  69.         case toolKeyDown:
  70.             /* non-modifier key pressed */
  71.             eventDataPtr = tDataPtr->evntRecPtr;
  72.             keyHit = (char)(charCodeMask & (eventDataPtr->message) );
  73.             if ( (keyHit >= '1') && (keyHit <= '3') )
  74.             {
  75.                 HLock( *refCon );
  76.                 fzDataPtr = (FuzzyDataPtr)**refCon;
  77.                 fzDataPtr->brushSize = (keyHit - 0x0030) * 16;
  78.                 HUnlock( *refCon );
  79.             }                
  80.             break;
  81.  
  82.         case toolMouseDown:
  83.             /* mouse down, set update area empty */
  84.             SetRect(&tDataPtr->updateRect,0,0,0,0);
  85.             if (! tDataPtr->linePatNone)
  86.                 tDataPtr->toolActive = true;
  87.             break;
  88.  
  89.         case toolStillDown:
  90.             /* mouse still down, draw something */
  91.             DrawEffect( tDataPtr, *refCon );
  92.             break;
  93.  
  94.         case toolMouseUp:        
  95.             /* mouse up */
  96.             SetRect(&tDataPtr->updateRect,0,0,0,0);
  97.             tDataPtr->toolActive = false;
  98.             break;
  99.  
  100.         case toolMenuEvent:
  101.             /* select new effect */
  102.             HLock( *refCon );
  103.             fzDataPtr = (FuzzyDataPtr)**refCon;
  104.             if ( tDataPtr->menuItem  != fzDataPtr->whichEffect )
  105.             {
  106.                 CheckItem( fzDataPtr->theMenu, fzDataPtr->whichEffect, false );
  107.                 CheckItem( fzDataPtr->theMenu, tDataPtr->menuItem, true );
  108.                 fzDataPtr->whichEffect = tDataPtr->menuItem;
  109.             }
  110.             HUnlock( *refCon );
  111.             break;
  112.  
  113.         case toolMenuDelete:
  114.             /* tool deselected, delete menu */
  115.             DeleteMenu( tDataPtr->toolID );
  116.             DrawMenuBar();        
  117.             break;
  118.  
  119.         default:
  120.             /* just clear the update area */
  121.             SetRect(&tDataPtr->updateRect,0,0,0,0);
  122.             break;
  123.             
  124.     }    /* end switch */
  125.  }
  126.